import { Location } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { UserService } from '@global/shared/user.service';
import { CookiesService } from 'ng-zorro-iop';

import { Environment } from '../../environments/environment';
import { FcsStatusService } from '../service/fcs-status.service';
@Component({
  selector: 'app-fcs-service-open',
  templateUrl: './fcs-suspended.component.html',
  styleUrls: ['./fcs-suspended.component.less']
})
export class FcsSuspendedComponent implements OnInit {
  isLoading = false;

  constructor(
    private router: Router,
    private location: Location,
    private cookieService: CookiesService,
    private userService: UserService,
    private fcsStatusService: FcsStatusService
  ) { }

  async ngOnInit() {
    // 服务未暂停，但直接访问路由的情况
    let ossResponse = await this.fcsStatusService.checkFcsSuspendStatus();
    console.log(ossResponse);
    let ossSuspended = !ossResponse || ossResponse.status !== 'normal' || ossResponse.status === 'stop';
    if (!ossSuspended) {
      this.router.navigate(['/overview']);
    }
  }

  jump2RechargePage(): void {
    // 跳转到充值页面
    window.open(Environment.application.bssFront + '/account/recharge');
  }

  jump2ConsoleIndex(): void {
    window.open(
      Environment.application.productUrl + '/console' + '/#/app-home',
      '_self'
    );
  }
}
